package com.qf.agro.controller;

import com.qf.agro.common.ResultInfo;
import com.qf.agro.pojo.Company;
import com.qf.agro.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.crypto.interfaces.PBEKey;

/**
 * @author 10202
 * @version V1.0
 * @Project smart-agriculture-parent
 * @Package com.qf.agro.controller
 * @Date 2023/5/22 20:23
 */
@RestController
public class CompanyController {
    private final CompanyService companyService;

    public CompanyController(CompanyService companyService) {
        this.companyService = companyService;
    }

    @GetMapping(value = "/company/page",name = "分页查询企业列表")
    public ResultInfo getList(@RequestParam(value = "page", defaultValue = "1") Long page,
                              @RequestParam(value = "pageSize", defaultValue = "5") Long pageSize, @RequestParam(value = "name",defaultValue = "") String name){

        return companyService.getCompanyList(page,pageSize,name);
    }

    @PutMapping("/company")
    public ResultInfo updateCompany(@RequestBody Company company){

        return companyService.updateCompany(company);
    }
    @PostMapping("/company")
    public ResultInfo addCompany(@RequestBody Company company){

        return companyService.addCompany(company);
    }


    @DeleteMapping("company")
    public ResultInfo deleteCompany(String id){
        System.out.println(1);
        return companyService.deleteCompany(id);
    }
}
